#include "../../include/dir.h"

//所有用户文件夹位置
#define USER_BASE_PATH "/home/zhou"

int init_user_path(path_t *path, const char*userName){
    bzero(path, sizeof(path_t));

    //初始化不变的用户根路径
    sprintf(path->initPath, "%s/%s", USER_BASE_PATH, userName);

    //初始化用户真实路径
    strncpy(path->realPath, path->initPath, MAX_PATH_LEN);

    //初始化用户虚拟路径
    strncpy(path->virtualPath, "/", MAX_PATH_LEN);

    //文件夹是否存在 不存在创建
    if(access(path->initPath, F_OK) != 0){
        printf("用户不存在，进行创建.\n");
        mkdir(path->initPath, 0755);
    }

    return 0;
}
